﻿namespace Tower_of_Hanoi
{
    internal class Program
    {
        /// <summary>
        /// 汉诺塔
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Console.Write("请输入盘子个数：");
            int N = int.Parse(Console.ReadLine());
            Hanoi(N, "A", "B", "C");
            Console.ReadKey();
        }
        static void Hanoi(int N, string start, string assist, string target)
        {
            if (N == 1)
            {
                Console.WriteLine($"编号为{N}的盘子从{start}移动到{target}");
                return;
            }
            else
            {
                Hanoi(N - 1, start, target,assist);
                Console.WriteLine($"编号为{N}的盘子从{start}移动到{target}");
                Hanoi(N - 1, assist, start, target);
            }
        }
    }
}